<template>
    <a-modal :confirm-loading="modalOption.loading" :okText="modalOption.okText" @ok="modalOption.onOk"
             @cancel="modalOption.onCancel" :cancelText="modalOption.cancelText" :width="modalOption.width" :visible="visible"
             :title="modalOption.title">
        <a-spin tip="loading" :spinning="loading">
            <div class="container">
                <a-form-model ref="formModel" :label-col="formOption.labelCol" :wrapper-col="formOption.wrapperCol"
                              :layout="formOption.layout" :label-align="formOption.labelAlign" :hide-required-mark="formOption.hideRequiredMark"
                              :rules="formOption.rules" :model="formOption.formData">
                    <div v-if="tabName =='C60'">
                        <div class="table">
                            <a-card hoverable>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="寄库日期" prop="storageDate" :rules="[{ required: true, message: '寄存日期不能为空' }]">
                                                <a-date-picker
                                                    valueFormat="YYYY-MM-DD"
                                                    class="inputs"
                                                    :locale="modalOption.locale" type="date"
                                                    v-model="formOption.formData.storageDate"
                                                    placeholder="寄库日期"
                                                    />
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="品名" prop="materialName" :rules="[{ required: true, message: '品名不能为空' }]">
                                                <a-select :disabled="disabledEdit" @change="materialNameChange" class="inputs" allowClear v-model="formOption.formData.materialName" placeholder="品名">
                                                    <a-select-option
                                                        v-for="(item,i) in searchSource.materialNameList"
                                                        :key="i"
                                                        :value="item.materialId">{{item.name}}</a-select-option>
                                                </a-select>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="批号" prop="batch" :rules="[{ required: true, message: '批号不能为空' }]">
                                                <a-input :disabled="disabledEdit" class="inputs" allowClear v-model="formOption.formData.batch" placeholder="批号"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="结存" prop="stockNumSys" :rules="[{ required: true, message: '结存不能为空' }]">
                                                <a-input :disabled="false" class="inputs" allowClear v-model="formOption.formData.stockNumSys" placeholder="结存"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="生产日期" prop="scTime" :rules="[{ required: true, message: '生产日期不能为空' }]">
                                                <a-date-picker
                                                    valueFormat="YYYY-MM-DD"
                                                    class="inputs"
                                                    :locale="modalOption.locale" type="date"
                                                    v-model="formOption.formData.scTime"
                                                    placeholder="生产日期"
                                                />
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="装量/g袋" prop="loadingQuantity">
                                                <a-input disabled class="inputs" allowClear v-model="formOption.formData.loadingQuantity" placeholder="装量"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="袋数" prop="bagNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.bagNum" placeholder="袋数"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="大袋" prop="bigBagNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.bigBagNum" placeholder="大袋"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="入库数量" prop="warehousingNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.warehousingNum" placeholder="入库数量"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="整件数量" prop="wholeNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.wholeNum" placeholder="整件数量"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="零件（大包装数量）" prop="spareBig">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.spareBig" placeholder="零件（大包装数量）"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="零件（中包装数量）" prop="spareMiddle">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.spareMiddle" placeholder="零件（中包装数量）"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="发货" prop="deliver">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.deliver" placeholder="发货"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="备注" prop="remark">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.remark" placeholder="备注"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="单号" prop="odd">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.odd" placeholder="单号"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="位置" prop="position">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.position" placeholder="位置"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="规格" prop="spec">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.spec" placeholder="规格"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="偏差" prop="deviation">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.deviation" placeholder="偏差"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="08库退" prop="eightReturn">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.eightReturn" placeholder="08库退"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="返工后" prop="rework">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.rework" placeholder="返工后"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                            </a-card>
                        </div>
                    </div>
                    <div v-if="tabName =='C70'">
                        <div class="table">
                            <a-card hoverable>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="寄存日期" prop="storageDate" :rules="[{ required: true, message: '寄存日期不能为空' }]">
                                                <a-date-picker
                                                    valueFormat="YYYY-MM-DD"
                                                    class="inputs"
                                                    :locale="modalOption.locale" type="date"
                                                    v-model="formOption.formData.storageDate"
                                                    placeholder="寄存日期"
                                                />
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="品名" prop="materialName" :rules="[{ required: true, message: '品名不能为空' }]">
                                                <a-select :disabled="disabledEdit" @change="materialNameChange" class="inputs" allowClear v-model="formOption.formData.materialName" placeholder="品名">
                                                    <a-select-option
                                                        v-for="(item,i) in searchSource.materialNameList"
                                                        :key="i"
                                                        :value="item.materialId">{{item.materialName}}</a-select-option>
                                                </a-select>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="批号" prop="batch" :rules="[{ required: true, message: '批号不能为空' }]">
                                                <a-input :disabled="disabledEdit" class="inputs" allowClear v-model="formOption.formData.batch" placeholder="批号"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="结存" prop="stockNumSys" :rules="[{ required: true, message: '结存不能为空' }]">
                                                <a-input :disabled="false" class="inputs" allowClear v-model="formOption.formData.stockNumSys" placeholder="结存"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="生产日期" prop="scTime" :rules="[{ required: true, message: '生产日期不能为空' }]">
                                                <a-date-picker
                                                    valueFormat="YYYY-MM-DD"
                                                    class="inputs"
                                                    :locale="modalOption.locale" type="date"
                                                    v-model="formOption.formData.scTime"
                                                    placeholder="生产日期"
                                                />
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="规格" prop="spec">
                                                <a-input :disabled="true" class="inputs" allowClear v-model="formOption.formData.spec" placeholder="规格"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="袋数" prop="bagNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.bagNum" placeholder="袋数"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="发货时间" prop="deliverTime">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.deliverTime" placeholder="发货时间"></a-input>
                                            </a-form-model-item>
                                        </a-col>

                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="发货数量" prop="deliverNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.deliverNum" placeholder="发货数量"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="位置" prop="position">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.position" placeholder="位置"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="单号" prop="odd">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.odd" placeholder="单号"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="偏差" prop="deviation">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.deviation" placeholder="偏差"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="08库退" prop="eightReturn">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.eightReturn" placeholder="08库退"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="返工后" prop="rework">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.rework" placeholder="返工后"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="微检情况" prop="inspectionStatus">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.inspectionStatus" placeholder="微检情况"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                            </a-card>
                        </div>
                    </div>
                    <div v-if="tabName =='C80'">
                        <div class="table">
                            <a-card hoverable>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="寄存日期" prop="storageDate" :rules="[{ required: true, message: '寄存日期不能为空' }]">
                                                <a-date-picker
                                                    valueFormat="YYYY-MM-DD"
                                                    class="inputs"
                                                    :locale="modalOption.locale" type="date"
                                                    v-model="formOption.formData.storageDate"
                                                    placeholder="寄存日期"
                                                />
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="品名" prop="materialName" :rules="[{ required: true, message: '品名不能为空' }]">
                                                <a-select :disabled="disabledEdit" @change="materialNameChange" class="inputs" allowClear v-model="formOption.formData.materialName" placeholder="品名">
                                                    <a-select-option
                                                        v-for="(item,i) in searchSource.materialNameList"
                                                        :key="i"
                                                        :value="item.materialId">{{item.materialName}}</a-select-option>
                                                </a-select>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="批号" prop="batch" :rules="[{ required: true, message: '批号不能为空' }]">
                                                <a-input :disabled="disabledEdit" class="inputs" allowClear v-model="formOption.formData.batch" placeholder="批号"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="结存" prop="stockNumSys" :rules="[{ required: true, message: '结存不能为空' }]">
                                                <a-input :disabled="false" class="inputs" allowClear v-model="formOption.formData.stockNumSys" placeholder="结存"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="生产日期" prop="scTime" :rules="[{ required: true, message: '生产日期不能为空' }]">
                                                <a-date-picker
                                                    valueFormat="YYYY-MM-DD"
                                                    class="inputs"
                                                    :locale="modalOption.locale" type="date"
                                                    v-model="formOption.formData.scTime"
                                                    placeholder="生产日期"
                                                />
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="装量/g袋" prop="loadingQuantity">
                                                <a-input disabled class="inputs" allowClear v-model="formOption.formData.loadingQuantity" placeholder="装量"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="袋数" prop="bagNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.bagNum" placeholder="袋数"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="大袋" prop="bigBagNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.bigBagNum" placeholder="大袋"></a-input>
                                            </a-form-model-item>
                                        </a-col>

                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="入库数量" prop="warehousingNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.warehousingNum" placeholder="入库数量"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="整件数量" prop="wholeNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.wholeNum" placeholder="整件数量"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="零件（大包装数量）" prop="spareBig">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.spareBig" placeholder="零件（大包装数量）"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="零件（中包装数量）" prop="spareMiddle">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.spareMiddle" placeholder="零件（中包装数量）"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="发货" prop="deliver">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.deliver" placeholder="发货"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="备注" prop="remark">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.remark" placeholder="备注"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="单号" prop="odd">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.odd" placeholder="单号"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="位置" prop="position">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.position" placeholder="位置"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="规格" prop="spec">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.spec" placeholder="规格"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="偏差" prop="deviation">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.deviation" placeholder="偏差"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="08库退" prop="eightReturn">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.eightReturn" placeholder="08库退"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="返工后" prop="rework">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.rework" placeholder="返工后"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                            </a-card>
                        </div>
                    </div>
                    <div v-if="tabName =='C90'">
                        <div class="table">
                            <a-card hoverable>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="寄存日期" prop="storageDate" :rules="[{ required: true, message: '寄存日期不能为空' }]">
                                                <a-date-picker
                                                    valueFormat="YYYY-MM-DD"
                                                    class="inputs"
                                                    :locale="modalOption.locale" type="date"
                                                    v-model="formOption.formData.storageDate"
                                                    placeholder="寄存日期"
                                                />
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="品名" prop="materialName" :rules="[{ required: true, message: '品名不能为空' }]">
                                                <a-select :disabled="disabledEdit" @change="materialNameChange" class="inputs" allowClear v-model="formOption.formData.materialName" placeholder="品名">
                                                    <a-select-option
                                                        v-for="(item,i) in searchSource.materialNameList"
                                                        :key="i"
                                                        :value="item.materialId">{{item.materialName}}</a-select-option>
                                                </a-select>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="批号" prop="batch" :rules="[{ required: true, message: '批号不能为空' }]">
                                                <a-input :disabled="disabledEdit" class="inputs" allowClear v-model="formOption.formData.batch" placeholder="批号"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="结存" prop="stockNumSys" :rules="[{ required: true, message: '结存不能为空' }]">
                                                <a-input :disabled="false" class="inputs" allowClear v-model="formOption.formData.stockNumSys" placeholder="结存"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="生产日期" prop="scTime" :rules="[{ required: true, message: '生产日期不能为空' }]">
                                                <a-date-picker
                                                    valueFormat="YYYY-MM-DD"
                                                    class="inputs"
                                                    :locale="modalOption.locale" type="date"
                                                    v-model="formOption.formData.scTime"
                                                    placeholder="生产日期"
                                                />
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="规格" prop="spec">
                                                <a-input :disabled="true" class="inputs" allowClear v-model="formOption.formData.spec" placeholder="规格"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="袋数" prop="bagNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.bagNum" placeholder="袋数"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="发货时间" prop="deliverTime">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.deliverTime" placeholder="发货时间"></a-input>
                                            </a-form-model-item>
                                        </a-col>

                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="发货数量" prop="deliverNum">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.deliverNum" placeholder="发货数量"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="位置" prop="position">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.position" placeholder="位置"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="入库单号" prop="odd">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.odd" placeholder="入库单号"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="偏差" prop="deviation">
                                                <a-input  class="inputs" allowClear v-model="formOption.formData.deviation" placeholder="偏差"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                                <div class="tool-bar">
                                    <a-row>
                                        <a-col :span="6">
                                            <a-form-model-item label="08库退" prop="eightReturn">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.eightReturn" placeholder="08库退"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="返工后" prop="rework">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.rework" placeholder="返工后"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                        <a-col :span="6">
                                            <a-form-model-item label="微检情况" prop="inspectionStatus">
                                                <a-input class="inputs" allowClear v-model="formOption.formData.inspectionStatus" placeholder="微检情况"></a-input>
                                            </a-form-model-item>
                                        </a-col>
                                    </a-row>
                                </div>
                            </a-card>
                        </div>
                    </div>
                </a-form-model>
            </div>
            <div slot="footer" style="text-align: center">
                <a-button size="large" @click="modalOption.onCancel">取 消</a-button>
                <a-button size="large" type="primary" @click="modalOption.onOk">确 定</a-button>
            </div>
        </a-spin>
    </a-modal>
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch } from "vue-property-decorator";
import locale from "ant-design-vue/lib/date-picker/locale/zh_CN";
import nextApi from "@/api/nextApi";
import areaJson, {getAreaWords} from "@/utils/area";
@Component({})
export default class extends Vue {
    @Prop({ default: false }) visible!: boolean;
    @Prop({ default: "" }) editId!: string;
    @Prop({ default: "" }) tabName!: string;
    @Prop({ default: "" }) formData!: object;
    @Watch("visible")
    visibleChange(val) {
        if (val) {
            this.getMaterialNameList()
        }else{
            //关闭弹窗初始化数据组
            this.searchSource = {
                materialNameList:[],
            };
            (this.$refs.formModel as any).resetFields()
            this.formOption.formData = {}
        }
    }
    loading = false
    disabledEdit = false
    @Watch("editId",{immediate:true})
    editIdChange(val) {
        if (val) {
            console.log('id:',val)
            this.modalOption.title = `编辑-${this.tabName}`;
            this.disabledEdit = true
            this.getInfo()
        }else{
            this.modalOption.title = `新增-${this.tabName}`;
        }
    }
    @Watch('tabName')
    tabNameChange(){
        this.editIdChange(this.editId)
    }
    //组件配置
    modalOption: any = {
        locale: locale,
        width: "90%",
        title: "新增",
        okText: "保存",
        cancelText: "取消",
        loading: false,
        onOk: () => {
            this.modalOk();
        },
        onCancel: () => {
            this.closeModal();
        },
    };

    //表单数据源
    searchSource:any = {
        materialNameList:[],//成品列表也就是查的产品管理的接口
    }
    //表单配置
    formOption: any = {
        labelCol: { style: { width: "140px" } },
        wrapperCol: { style: {width:'calc(100% - 140px)'}},
        layout: "inline",
        labelAlign: "right",
        hideRequiredMark: false,
        formData: {},
        rules: {},
    };
    //品名选择
    materialNameChange(v){
        let find = this.searchSource.materialNameList.find(item=>item.materialId === v)
        if(find){
            this.formOption.formData.loadingQuantity = find.loadingQuantity
            this.formOption.formData.spec = find.spec
            this.formOption.formData.materialName = find.name
        }
        this.loading = false
    }
    //查询详情后进行修改
    async getInfo(){
        this.loading = true
        this.formOption.formData = this.formData
        setTimeout(()=>{
            this.loading = false
        },400)
    }
    //提交
    modalOk(){
        (this.$refs.formModel as any).validate(async (valid: boolean) => {
            if (valid) {
                this.modalOption.loading = true;
                try {
                    if(this.editId){
                        this.formOption.formData.inventoryType = this.tabName
                        console.log(this.formOption.formData,'修改')
                        const res = await nextApi.productStorageUpdateProd(this.formOption.formData)
                        this.$message.success(res.msg)
                        this.$emit("closeModal")
                    }else{
                        this.formOption.formData.inventoryType = this.tabName
                        console.log(this.formOption.formData,'新增')
                        const res = await nextApi.productStorageAdd(this.formOption.formData)
                        this.$message.success(res.msg)
                        this.$emit("closeModal")
                    }
                }finally {
                    this.modalOption.loading = false;
                }
            }
        });
    }
    /**
     * @description 查询一些数据
     * **/
    async getMaterialNameList(){
        this.loading = true
        const res = await nextApi.selectMaterialListByType({inventoryType:this.tabName})
        this.searchSource.materialNameList = res.data
        this.loading = false
    }
    closeModal() {
        this.disabledEdit = false
        this.$emit("closeModal");
    }
}
</script>
<style scoped lang="scss">
.container {
    padding: 0;
    .MR-10 {
        margin-right: 10px;
    }
    .inputs {
        width: 200px;
    }
    .inputs-with-qus{
        width: 173px;
    }
    .tool-bar {
        margin-bottom: 20px;

    }
    .table {
        margin-top: 20px;
    }
}
</style>
